﻿using Jay.Sc2.Bof.Lib.State;

namespace Jay.Sc2.Bof.Lib.Action.Protoss
{
	public class ActionProduceWarpGate : ActionProduceProtoss
	{
		public static ActionProduceWarpGate Instance = new ActionProduceWarpGate();
		private ActionProduceWarpGate() : base(10, 0, 0, 0) { }
		public override void Execute(IBuildOrder bo)
		{
			ProtossState state = bo.State as ProtossState;
			base.Execute(bo);
			state.Gateway.Production++;
			state.WarpGate.Building++;
			bo.AddAction(state.Time + BuildTime, new ActionGeneric("ActionSpawnWarpGate", (ActionGeneric.ActionExecuteDelegate)delegate(IBuildOrder ibo)
			{
				ProtossState ibostate = ibo.State as ProtossState;
				state.WarpGate.Built();
				state.Gateway.Count--;
				state.Gateway.Production--;
			}));
		}
		public override bool HaveTechnology(IBuildOrder bo)
		{
			ProtossState state = bo.State as ProtossState;
			return state.GatewayToWarpGate.Available;
		}
		public override bool IsInvalid(IBuildOrder bo)
		{
			ProtossState state = bo.State as ProtossState;
			return base.IsInvalid(bo) || !state.GatewayToWarpGate.Have || state.Gateway.Total == 0;
		}
		public override int AvailableProducer(IBuildOrder bo)
		{
			ProtossState state = bo.State as ProtossState;
			return state.Gateway.AvailableForProduction;
		}
		private IAction[,] m_Requirements;
		public override IAction[,] Requirements
		{
			get
			{
				if (m_Requirements == null)
					m_Requirements = new IAction[,] { { ActionUpgradeGatewayToWarpGate.Instance } };
				return m_Requirements;
			}
		}
		private IAction[,] m_Inputs;
		public override IAction[,] Inputs
		{
			get
			{
				if (m_Inputs == null)
					m_Inputs = new IAction[,] { { ActionProduceGateway.Instance } };
				return m_Inputs;
			}
		}
	}
}
